<html>
<head><meta charset="utf-8"><title>Resolving a QPath to an Instance · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolving.20a.20QPath.20to.20an.20Instance.html">Resolving a QPath to an Instance</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="233650182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolving%20a%20QPath%20to%20an%20Instance/near/233650182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolving.20a.20QPath.20to.20an.20Instance.html#233650182">(Apr 08 2021 at 13:16)</a>:</h4>
<p>I'm currently working on adding support for <code>sym</code> operands to <code>global_asm!</code>. Some background: <code>global_asm("jmp {}", sym foo)</code> causes the symbol name of <code>foo</code> to be emitted directly into the assembly code (<code>foo</code> can be a <code>fn</code> or a <code>static</code>).</p>



<a name="233650709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolving%20a%20QPath%20to%20an%20Instance/near/233650709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolving.20a.20QPath.20to.20an.20Instance.html#233650709">(Apr 08 2021 at 13:20)</a>:</h4>
<p>I'm currently representing this in the HIR as a <code>QPath</code> in <code>ItemKind::GlobalAsm</code>. However I don't know how to get from there to an <code>Instance</code> for a monomorphized function (<code>sym foo::&lt;i32&gt;</code>). I can get the <code>DefId</code> for the function from the <code>QPath::Resolved</code> but I don't know how to get the <code>Substs</code> for it (taking into account things like defaulted type parameters, etc).</p>



<a name="233651120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolving%20a%20QPath%20to%20an%20Instance/near/233651120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolving.20a.20QPath.20to.20an.20Instance.html#233651120">(Apr 08 2021 at 13:23)</a>:</h4>
<p>Note that all of this is happening outside a body so I don't have a typeck context to work with.</p>



<a name="233655452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolving%20a%20QPath%20to%20an%20Instance/near/233655452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolving.20a.20QPath.20to.20an.20Instance.html#233655452">(Apr 08 2021 at 13:52)</a>:</h4>
<p>Maybe I should just stick the whole thing in an <code>AnonConst</code> and let typeck figure it out?</p>



<a name="233693045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolving%20a%20QPath%20to%20an%20Instance/near/233693045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolving.20a.20QPath.20to.20an.20Instance.html#233693045">(Apr 08 2021 at 17:20)</a>:</h4>
<p><span class="user-mention silent" data-user-id="143274">Amanieu</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Resolving.20a.20QPath.20to.20an.20Instance/near/233655452">said</a>:</p>
<blockquote>
<p>Maybe I should just stick the whole thing in an <code>AnonConst</code> and let typeck figure it out?</p>
</blockquote>
<p>+1<br>
There has to be a body to do what want, and <code>AnonConst</code> should be the simplest way to create it.</p>



<a name="233774569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Resolving%20a%20QPath%20to%20an%20Instance/near/233774569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Resolving.20a.20QPath.20to.20an.20Instance.html#233774569">(Apr 09 2021 at 06:36)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> One issue is that <code>AnonConst</code> doesn't allow referring to statics. So I would need to create a custom body type for this.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>